<?php

session_start();
include('system/db/conn.php');
$id=$_GET['id'];
$function=$_GET['function'];


if($function==0){


$sql = "update do_user_consignee set isdefult='0' where user_id=".$_SESSION['userid'];

if(mysql_query($sql,$conn)){
	$check_query2 = mysql_query("update do_user_consignee set isdefult='1' where id=".$id);
	
	if(mysql_query($check_query2,$conn)){
	}

	header('location:member-add.php');

}
	
}elseif ($function==1) {
	echo "编辑";
}elseif ($function==2) {
	$check_query2 ="delete from do_user_consignee  where id=".$id;
	if(mysql_query($check_query2,$conn)){
		$check_query = mysql_query("select id from do_user_consignee where user_id=".$_SESSION['userid']." and isdefult='1' limit 1");
	   	echo $check_query;
	
	   if(mysql_fetch_array($check_query)){
    		
		}else{
		$check_query3 = mysql_query("select id from do_user_consignee where user_id=".$_SESSION['userid']." limit 1");
	   while($row = mysql_fetch_array($check_query3)){
 		$littlesql=mysql_query("update do_user_consignee set isdefult='1' where id=".$row['id']);

	   }
}

	}

	header('location:member-add.php');

}

?>